<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/ueditor/ueditor.config.js"></script>
    <script src="/ueditor/ueditor.all.min.js"></script>
    <script src="/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>

<!--开发步骤
    1.将富文本文件引入进来
    2.编写controller代替controller.jsp
    3.将config.json拷贝到templates下而不是放到源文件下
    4.在ueditor.config.js

	  添加： var server_url = window.location.protocol + "//"+window.location.hostname+":"+window.location.port;
	   修改：   serverUrl: server_url + "/config"  config为后台写的controller映射地址，这里是富文本最先加载的地方

-->

    <div id="goodsApp">
        职位名称:
        <input type="text"  id="jobName"  /><br/>
        行业分类:
        <input type="text"  id="jobIndustry"  /><br/>
        工作城市:
        <input type="text"  id="jobPlace"  /><br/>
        学历要求:
        <input type="text"  id="jobEdu"  /><br/>
        岗位描述和职责:
        <textarea  id="container"  name="content" type="text/plain"></textarea>
        薪资详情:
        <input type="text"  id="jobSalary"  /><br/>
        招聘类型:
        <input type="text"  id="jobType"  /><br/>
        接受邮箱:
        <input type="text"  id="email"  /><br/>
        <button onclick="add()">添加</button>
        <br/><br/><br/>
        ---------------------修改-----------------------
        请输入要修改的id:<br/>
        <input type="text"  id="ueditorId"  /><br/>
        <button onclick="findOne()">查找</button>

        <br/>
        <br/>
        <br/>
        ---------------------显示-----------------------

        <div id="showid">

        </div>

    </div>
    <!--<script src="/goods.js"></script>-->
    <script type="text/javascript">
        //下面是自定义标签
        // var editor = UE.getEditor('container',{
        //     toolbars: [
        //         ['fullscreen', 'source', 'undo', 'redo'],
        //         ['bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc']
        //     ]
        // });
        //上面是自定义标签

        var editor = UE.getEditor('container');

        function  showAll() {

        }
        //findOne
        function findOne() {
            var ueditorId =$("#ueditorId").val();
            console.info("ueditorId:"+ueditorId);
            $.ajax({
                url:"/goods/findone",
                dataType:"json",
                data:{"id":ueditorId},
                type:"get",
                success:function(result){
                    console.info("msg"+result.msg);
                    var server_url = window.location.protocol + "//"+window.location.hostname+":"+window.location.port;
                    console.info("server_url="+server_url);
                    console.info("msg="+result.msg+"content="+result.content)
                    editor.setContent(result.data.content);
                    $("#showid").append(result.data.content);
                }
            })
        }

        //添加
        function add() {
            var jobName =$("#jobName").val();
            var jobIndustry =$("#jobIndustry").val();
            var jobPlace =$("#jobPlace").val();
            var jobEdu =$("#jobEdu").val();
            var jobSalary =$("#jobSalary").val();
            var jobType =$("#jobType").val();
            var email =$("#email").val();
            var content = editor.getContent();
            console.info("content:"+content)
            $.ajax({
                url:"/job/save",
                dataType:"json",
                data:{"jobName":jobName,"jobIndustry":jobIndustry,"jobPlace":jobPlace,"jobEdu":jobEdu,
                    "jobSalary":jobSalary,"jobType":jobType,"email":email,"jobDetails":content},
                type:"put",
                success:function(result){
                    console.info("msg="+result.msg);
                }
           })
        }
    </script>
</body>
</html>

